#include <bits/stdc++.h>
using namespace std;
const int N = 1001;
int x[N], y[N], w[N];
int dp[601][601];
//  设dp[i][g][s]是可选物品为1,2....i,得到金为g，得到银为s时的二维0-1背包问题的最优值
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i] >> w[i];
  }
  memset(dp, 0x3f, sizeof(dp));

  // for (int g = 900; g >= 0; g--) {
  //   for (int s = 900; s >= 0; s--) {
  //     dp[0][g][s]=0;
  //   }
  // }
  // dp[1][0][0] = 0;
  dp[0][0] = 0;

  for (int i = 1; i <= n; i++) {
    for (int g = 600; g >= 0; g--) {
      for (int s = 600; s >= 0; s--) {
        if (g >= x[i] && s >= y[i]) {
          int k = dp[g - x[i]][s - y[i]] + w[i];
          dp[g][s] = min(dp[g][s], k);
        }
      }
    }
  }
  int ans = 0x3f3f3f3f;
  for (int g = a; g <= 600; g++) {
    for (int s = b; s <= 600; s++) {
      ans = min(ans, dp[g][s]);
    }
  }
  cout << ans;
  return 0;
}